package cn.xz.tipsum.activity

import android.os.Bundle
import android.util.DisplayMetrics
import android.util.Log
import android.view.WindowManager
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import cn.xz.tipsum.R
import cn.xz.tipsum.databinding.ActivityDeviceBinding
import cn.xz.tipsum.databinding.ActivityVideoBinding
import cn.xz.tipsum.dialog.LoadingDialog
import cn.xz.tipsum.utils.AppHelper
import cn.xz.tipsum.utils.DownloadUtil
import cn.xz.tipsum.utils.MD5Utils
import java.io.File

class VideoActivity : AppCompatActivity() {

    private var mDataBind: ActivityVideoBinding? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
        mDataBind = DataBindingUtil.setContentView(this, R.layout.activity_video)
        initData()
        initEvent()
    }

    private fun initData(){
        mDataBind?.apply {
            vv.setVideoPath("http://www.hualao.icu/video.mp4")
            vv.requestFocus()
            vv.start()
        }


    }

    private fun initEvent(){
        mDataBind?.apply {
            tvBack.setOnClickListener {
                finish()
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        mDataBind?.vv?.stopPlayback()
        mDataBind?.vv?.setOnPreparedListener(null);
        mDataBind?.vv?.destroyDrawingCache();
    }

}